/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 17655
 * Date: 2025-05-22
 * Time: 19:02
 */
public class test2 {
    public static String LongStr(String[] strs){
        if(strs.length==0){
            return "";
        }
        String str = strs[0];
        for(int i=1;i<strs.length;i++){
            while(strs[i].indexOf(str)!=0){
                str = str.substring(0,str.length()-1);
                if(str.isEmpty()){
                    return "";
                }
            }
        }
        return str;
    }

    public static void main(String[] args){
        String[] strs = {"flower","flow","flight"};
        String result = LongStr(strs);
        System.out.println(result);
    }
}
